﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Globalization;
namespace plvs
{
    public partial class Form1 : Form
    {

        #region Variables And Objects

        RegFunctions rf1 = new RegFunctions();
        int _timer = 0;
        #endregion
        public Form1()
        {
            InitializeComponent();
            int _runningcount = Properties.Settings.Default.RunningCount;
            //_runningcount++;
            //Properties.Settings.Default.RunningCount = _runningcount;
            //Properties.Settings.Default.Save();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            new PublicClass1().PlaySoundFromLoad();
        }
        
        private void timer1_Tick(object sender, EventArgs e)
        {
            _timer++;
            switch (_timer)
            {
                case 1 :
                    try
                    {
                        Properties.Settings.Default.InternetConection = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error Internet Connection . . . ");
                    }
                    break;
                case 2 :
                    // Chenge Lang
                    //using System.Globalization;
                     //InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new CultureInfo("FA"));
                    try
                    {
                        InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new CultureInfo("fa-IR"));

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    break;
                case 3:
                    //Attach DataBase

                    break;
                case 99 :
                    // Change And Create Register Key
                    try
                    {
                        timer1.Enabled = false;
                        if((rf1.CheckReg()) || (Properties.Settings.Default.RunningCount <= 10 ))
                        {
                            MessageBox.Show((10 - Properties.Settings.Default.RunningCount).ToString() + " Times to Registering time . . .","Warning",MessageBoxButtons.OK,MessageBoxIcon.Information);
                            this.Hide();
                            new frmLogin().Show();
                        }
                        else
                        {
                            this.Hide();
                            //new ().Show();
                            new plvs.Reg.frmRegNew().Show();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Test");
                    }
                     break;
            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}
